Add --editor-mode flag when invoking rubocop#5049
Merged
hsanson merged 2 commits intodense-analysis:masterfrom Oct 26, 2025
Merged
Add --editor-mode flag when invoking rubocop#5049hsanson merged 2 commits intodense-analysis:masterfrom
hsanson merged 2 commits intodense-analysis:masterfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
5ed3b48 to
3b189b3
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Since RuboCop 1.61.0 (released in February 2024), RuboCop accepts an `--editor-mode` flag which improves editor integrations like ale. Some of RuboCop's auto-corrections can be surprising or annoying to run on save. When RuboCop is running via an LSP or when the `--editor-mode` flag is passed, it will understand that it is running in an editor, and it will hold off on making changes that might be surprising or annoying. For example, if I write ```ruby def call results = some_process end ``` This has an unused variable, and RuboCop will remove the unused variable when you run it. However, if you're in the middle of editing, you may not want it to remove that unused variable, because you may be about to add a usage of it. More context: - PR which introduced it: rubocop/rubocop#12682 - Release notes for 1.61: https://github.com/rubocop/rubocop/releases/tag/v1.61.0 - Docs: https://docs.rubocop.org/rubocop/1.80/configuration.html#contextual This will be a breaking change for anyone who is running an old version of RuboCop, because the flag will not exist for them. If they would like to opt out of this change, they can set an option to omit the flag. I think this ought to be enabled by default so that people will get this benefit out of the box. In the meantime, I am opting into this behavior by setting this option: ```vim let g:ale_ruby_rubocop_options = "--editor-mode" ``` So I appreciate that this seam was already introduced.
3b189b3 to
b8a90cf
Compare
hsanson
requested changes
Sep 21, 2025
Contributor
hsanson
left a comment
There was a problem hiding this comment.
There is no need to make this a breaking change. Ale has ale#semver#RunWithVersionCheck helper method that allows to set different commands based on the tool version.
Check golangci-lit fixer for an example or search for that function in ALE's code as there are many examples using it.
ede0f44 to
9697fdb
Compare
This will detect the current rubocop version and auto-enable --editor-mode for newer version of rubocop without affecting users of older versions of rubocop.
9697fdb to
b4b228c
Compare
Contributor
Author
Thanks for bringing this to my attention! I've updated the implementation in b4b228c. What do you think? |
Contributor
Author
|
👍 thanks for your help! |
Caw3
pushed a commit
to Caw3/ale
that referenced
this pull request
Dec 10, 2025
* Add --editor-mode flag when invoking rubocop Since RuboCop 1.61.0 (released in February 2024), RuboCop accepts an `--editor-mode` flag which improves editor integrations like ale. Some of RuboCop's auto-corrections can be surprising or annoying to run on save. When RuboCop is running via an LSP or when the `--editor-mode` flag is passed, it will understand that it is running in an editor, and it will hold off on making changes that might be surprising or annoying. For example, if I write ```ruby def call results = some_process end ``` This has an unused variable, and RuboCop will remove the unused variable when you run it. However, if you're in the middle of editing, you may not want it to remove that unused variable, because you may be about to add a usage of it. More context: - PR which introduced it: rubocop/rubocop#12682 - Release notes for 1.61: https://github.com/rubocop/rubocop/releases/tag/v1.61.0 - Docs: https://docs.rubocop.org/rubocop/1.80/configuration.html#contextual This will be a breaking change for anyone who is running an old version of RuboCop, because the flag will not exist for them. If they would like to opt out of this change, they can set an option to omit the flag. I think this ought to be enabled by default so that people will get this benefit out of the box. In the meantime, I am opting into this behavior by setting this option: ```vim let g:ale_ruby_rubocop_options = "--editor-mode" ``` So I appreciate that this seam was already introduced. * Make this a non-breaking change This will detect the current rubocop version and auto-enable --editor-mode for newer version of rubocop without affecting users of older versions of rubocop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since RuboCop 1.61 (released in February 2024), RuboCop accepts an
--editor-modeflag which improves editor integrations like ale.Some of RuboCop's auto-corrections can be surprising or annoying to run on save. When RuboCop is running via an LSP or when the
--editor-modeflag is passed, it will understand that it is running in an editor, and it will hold off on making changes that might be surprising or annoying.For example, if I write
This has an unused variable, and RuboCop will remove the unused variable when you run it. However, if you're in the middle of editing, you may not want it to remove that unused variable, because you may be about to add a usage of it.
More context:
--editor-modeCLI option rubocop/rubocop#12682AutoCorrect: contextualto be aware of non-LSP editor integrations rubocop/rubocop#14539In order to make sure this isn't a breaking change for ale users who use an older version of RuboCop, this implementation only enables the
--editor-modeflag when the version of RuboCop is >= 1.61.0.In the meantime, I am opting into this behavior by setting this option:
So I appreciate that this seam was already introduced.